<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      html {
        background: #1e1e1e;
      }
      .bubble {
        background: red;
        width: 100px;
        height: 100px;
        border-radius: 50%;
        position: fixed;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        animation: fadeout 1s forwards;
      }

      @keyframes fadeout {
        to {
          opacity: 0;
          transform: translate(-50%, -500%);
        }
      }
    </style>
  </head>
  <body>
    <!-- <div class="bubble"></div> -->

    <script>
      var lock = false;

      function getRandom(min, max) {
        return Math.floor(Math.random() * (max - min) + min);
      }
      window.addEventListener('mousemove', function (e) {
        if (lock) {
          return;
        }
        lock = true;
        setTimeout(function () {
          lock = false;
        }, 10);
        var div = document.createElement('div');
        div.className = 'bubble';
        document.body.appendChild(div);

        div.style.left = e.clientX + 'px';
        div.style.top = e.clientY + 'px';

        var size = getRandom(10, 50);
        div.style.width = div.style.height = size + 'px';

        var r = getRandom(0, 256);
        var g = getRandom(0, 256);
        var b = getRandom(0, 256);

        div.style.background = `rgb(${r},${g},${b})`;

        div.addEventListener('animationend', function () {
          div.remove();
        });
      });
    </script>
  </body>
</html>
